#include <Arduino.h>

// put function declarations here:
int led_pin = 3;
int pir_pin = 2;

void setup()
{
  // put your setup code here, to run once:
  pinMode(pir_pin, INPUT);
  pinMode(led_pin, OUTPUT);

  Serial.begin(9600);
}

void loop()
{
  // put your main code here, to run repeatedly:
  int pir_val = digitalRead(pir_pin);
  if (pir_val == HIGH)
  {
    Serial.println("light on");
    digitalWrite(led_pin, HIGH);
    while (true)
    {
      bool off = true;
      for (int i = 0; i < 10; i++)
      {
        delay(500);
        pir_val = digitalRead(pir_pin);
        if (pir_val == HIGH)
        {
          off = false;
          break;
        }
      }
      if (off)
      {
        break;
      }
    }

    Serial.println("light off");
    digitalWrite(led_pin, LOW);
  }
}

// put function definitions here: